# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     day140_pyqt5_qinputdialog
   Description :
   Author :       fuml
   date：          2019/9/21
-------------------------------------------------
   Change Activity:
                   2019/9/21:In this example, we determine the event sender
object.
-------------------------------------------------
"""

import  sys
from PyQt5.QtWidgets import (QPushButton,QLineEdit,QWidget,QInputDialog,QApplication)

class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.btn=QPushButton('dialog',self)
        self.btn.move(20,20)
        self.btn.clicked.connect(self.showDialog)

        self.le=QLineEdit(self)
        self.le.move(20,50)

        self.setGeometry(300,300,250,150)
        self.setWindowTitle('Input Dialog')
        self.show()

    def showDialog(self):
        text,ok = QInputDialog.getText(self,'Input Dialog','Enter your name:')
        if ok:
            self.le.setText(str(text))

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())